package net.lijingye.education.vo;

import com.alibaba.fastjson.annotation.JSONField;
import com.alibaba.fastjson.serializer.SerializerFeature;
import net.lijingye.education.entity.Assignment;
import net.lijingye.education.entity.StudentAssignment;
import net.lijingye.education.util.CommonUtil;

import java.util.Date;

/**
 * Created by LijingYe on 2016/3/26.
 */
public class AssignmentVO {
    @JSONField(name = "id", ordinal = 0, serialzeFeatures = SerializerFeature.WriteMapNullValue)
    private String id;
    @JSONField(name = "lessonId", ordinal = 1, serialzeFeatures = SerializerFeature.WriteMapNullValue)
    private String lessonId;
    @JSONField(name = "lessonName", ordinal = 2, serialzeFeatures = SerializerFeature.WriteMapNullValue)
    private String lessonName;
    @JSONField(name = "title", ordinal = 3, serialzeFeatures = SerializerFeature.WriteMapNullValue)
    private String title;
    @JSONField(name = "time", ordinal = 4, serialzeFeatures = SerializerFeature.WriteMapNullValue, format = "yyyy/MM/dd HH:mm")
    private Date time;
    @JSONField(name = "endTime", ordinal = 5, serialzeFeatures = SerializerFeature.WriteMapNullValue, format = "yyyy/MM/dd")
    private Date endTime;
    @JSONField(name = "status", ordinal = 6, serialzeFeatures = SerializerFeature.WriteMapNullValue)
    private String status;
    @JSONField(name = "content", ordinal = 7, serialzeFeatures = SerializerFeature.WriteMapNullValue)
    private String content;
    @JSONField(name = "isHaveSolution", ordinal = 8, serialzeFeatures = SerializerFeature.WriteMapNullValue)
    private Boolean isHaveSolution;
    @JSONField(name = "isUploaded", ordinal = 9, serialzeFeatures = SerializerFeature.WriteMapNullValue)
    private Boolean isUploaded;

    public AssignmentVO(Assignment assignment, StudentAssignment studentAssignment) {
        this.id = assignment.getId();
        this.lessonId = assignment.getLesson().getId();
        this.lessonName = assignment.getLesson().getCourse().getName();
        this.title = assignment.getTitle();
        this.time = assignment.getTime();
        this.endTime = assignment.getEndTime();
        this.content = assignment.getContent();
        if (assignment.isNeedSubmit()) {
            if (null == studentAssignment) {
                this.status = "未提交";
            } else {
                this.status = "已提交";
            }
        } else {
            this.status = "无需提交";
        }
        this.isHaveSolution = (null != assignment.getAnswer());
        this.isUploaded = (null != studentAssignment);
    }

    public AssignmentVO(String id, String lessonId, String lessonName, String title, Date time, Date endTime, String status, String content, Boolean isHaveSolution, Boolean isUploaded) {
        this.id = id;
        this.lessonId = lessonId;
        this.lessonName = lessonName;
        this.title = title;
        this.time = time;
        this.endTime = endTime;
        this.status = status;
        this.content = content;
        this.isHaveSolution = isHaveSolution;
        this.isUploaded = isUploaded;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getLessonId() {
        return lessonId;
    }

    public void setLessonId(String lessonId) {
        this.lessonId = lessonId;
    }

    public String getLessonName() {
        return lessonName;
    }

    public void setLessonName(String lessonName) {
        this.lessonName = lessonName;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public Date getTime() {
        return time;
    }

    public void setTime(Date time) {
        this.time = time;
    }

    public Date getEndTime() {
        return endTime;
    }

    public void setEndTime(Date endTime) {
        this.endTime = endTime;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public Boolean getHaveSolution() {
        return isHaveSolution;
    }

    public void setHaveSolution(Boolean haveSolution) {
        isHaveSolution = haveSolution;
    }

    public Boolean getUploaded() {
        return isUploaded;
    }

    public void setUploaded(Boolean uploaded) {
        isUploaded = uploaded;
    }

    @Override
    public String toString() {
        return "AssignmentVO{" +
                "id='" + id + '\'' +
                ", lessonId='" + lessonId + '\'' +
                ", lessonName='" + lessonName + '\'' +
                ", title='" + title + '\'' +
                ", time=" + time +
                ", endTime=" + endTime +
                ", status='" + status + '\'' +
                ", content='" + content + '\'' +
                ", isHaveSolution=" + isHaveSolution +
                ", isUploaded=" + isUploaded +
                '}';
    }
}
